<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>登录</title>
	<link rel="stylesheet" type="text/css" href="__STATIC__/yt_css/initialize.css" />
	<link rel="stylesheet" type="text/css" href="__STATIC__/yt_css/ipad.css" />
	<link rel="stylesheet" type="text/css" href="__STATIC__/yt_css/iPhone.css" />
	<link rel="stylesheet" type="text/css" href="__STATIC__/yt_css/style.css" />
	<link rel="stylesheet" type="text/css" href="__STATIC__/yt_css/swiper.css" />
    <script type="text/javascript" src="__STATIC__/yt_js/jquery-1.9.0.min.js"></script>
    <script src="__PUBLIC__/static/js/layer/layer.js" type="text/javascript"></script>
</head>
	<body class="body1">
		<div class="container">
            <include file="user/new_header"/>
			<div class="register login">
                <form id="loginform" method="post">
					<div class="zong">
						<div class="bor">
							<input class="username" type="text"  placeholder="手机号码" id="username" name="username" autocomplete="off" value="">
						</div>
						<div class="bor">
							<input class="password" type="password" placeholder="密码"id="password" name="password"  autocomplete="off"  value="">
						</div>
						<div class="bor" >
                            <input class="verify" type="text"  placeholder="验证码" id="verify_code" name="verify_code" autocomplete="off" value="">
                            <div class="yzm">
                                <img src="/index.php?m=Home&c=User&a=verify" id="verify_code_img" onclick="verify()" width="160" height="50" />
                            </div>

						</div>
						<a href="">忘记密码？</a>
					</div>
                </form>
					<div class="btn">
						<button onclick="checkSubmit()">登录</button>
                        <a style="text-align: center; margin-top: 10px" href="{:U('Home/User/reg')}">还没有账号，
                        <span style="color: #FF4466">立即注册</span></a>
					</div>

			</div>
			<div class="zhanwei"></div>
            <include file="public/new_footer"/>
		</div>

        <script>
        function checkSubmit()
        {
            var username = $.trim($('#username').val());
            var password = $.trim($('#password').val());
            var referurl = $('#referurl').val();
            var verify_code = $.trim($('#verify_code').val());
            if(username == ''){
            showErrorMsg('用户名不能为空!');
            return false;
            }
            if(!checkMobile(username) && !checkEmail(username)){
            showErrorMsg('账号格式不匹配!');
            return false;
            }
            if(password == ''){
            showErrorMsg('密码不能为空!');
            return false;
            }
           // if(verify_code == ''){
           // showErrorMsg('验证码不能为空!');
           // return false;
           // }
            $.ajax({
            type : 'post',
            url : '/index.php?m=Home&c=User&a=do_login&t='+Math.random(),
            data : $('#loginform').serialize(),
            dataType : 'json',
            success : function(res){
            if(res.status == 1){
            window.location.href = res.url;
            }else{
            showErrorMsg(res.msg);
            verify();
            }
            },
            error : function(XMLHttpRequest, textStatus, errorThrown) {
            showErrorMsg('网络失败，请刷新页面后重试');
            }
            })

            }
        function checkMobile(tel) {
            var reg = /(^1[3|4|5|7|8][0-9]{9}$)/;
            if (reg.test(tel)) {
                return true;
            }else{
                return false;
            };
        }

        function checkEmail(str){
            var reg = /^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
            if(reg.test(str)){
                return true;
            }else{
                return false;
            }
        }

        function showErrorMsg(msg){
            layer.alert(msg, {icon: 2});
//        $('.msg-err').show();
//        $('.J-errorMsg').html(msg);
        }

		function verify(){
			$('#verify_code_img').attr('src','/index.php?m=Home&c=User&a=verify&r='+Math.random());
		}
        </script>
    </body>

</html>